package ink.metoo.gude.module.game.util

import ink.metoo.gude.module.security.domain.ddl.User
import ink.metoo.gude.module.game.domain.ddl.GameEvent
import ink.metoo.gude.module.game.domain.GameEventType
import ink.metoo.gude.module.game.domain.ddl.GameRoom
import ink.metoo.gude.util.JsonUtils
import java.util.*

object GameRoomUtils

fun GameRoom.createEvent(
    eventType: GameEventType,
    player: User?,
    record: Any? = null,
): GameEvent {
    val event = GameEvent()
    event.type = eventType.type
    event.player = player
    event.record = JsonUtils.toJson(record)
    event.gameRoom = this
    event.createDate = Date()
    return event
}